package com.microinvest.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.List;

public class ChangeListAndJsonUtil {
    public static String ChangeToJson(List<List<Double>> data) throws Exception {
        ObjectMapper objectMapper = new ObjectMapper();
        return objectMapper.writeValueAsString(data);
    }

    public static List<List<Double>> ChangeToList(String stockJson) throws Exception {
        ObjectMapper objectMapper = new ObjectMapper();
        return objectMapper.readValue(stockJson, new TypeReference<List<List<Double>>>() {});
    }
}
